package com.chzu.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chzu.mapper.ReadScoreMapper;
import com.chzu.pojo.ReadScore;
import com.chzu.pojo.SysUser;
import com.chzu.pojo.vo.ScoreChartDateVo;
import com.chzu.pojo.vo.SemesterAndReadScoreVo;
import com.chzu.service.ReadScoreService;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author lz
 * @Version 1.0
 * @Company 滁州大健康与养老产业研究院
 * @ClassName ReadScoreServiceImpl
 * @Description TODO
 * @Date 2022/02/10 22:14
 */
@Service
public class ReadScoreServiceImpl extends ServiceImpl<ReadScoreMapper, ReadScore> implements ReadScoreService {

    @Resource
    private ReadScoreMapper readScoreMapper;

    /**
     * 获取用户阅读推文所得的积分
     * @return
     */
    @Override
    public ReadScore getReadScore() {
        SysUser user = (SysUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return readScoreMapper.getReadScore(user.getOpenId());
    }

    /**
     * 获取各个阅读推文积分段人数
     * @return
     */
    @Override
    public List<ScoreChartDateVo> getStudentNumByScore() {
        return readScoreMapper.getStudentNumByScore();
    }
}
